如何讓我的代碼在Visual Basic中停止? 您所在的位置:网站首页 visual basic教材 如何讓我的代碼在Visual Basic中停止?

如何讓我的代碼在Visual Basic中停止?

#如何讓我的代碼在Visual Basic中停止?| 来源: 网络整理| 查看: 265

我正在創建一個遊戲,玩家回答一個問題,然後如果他們回答正確,那麼他們會翻轉兩張牌,看看他們是否匹配(有點像雙人遊戲)。然而,我正在努力弄清楚,如果玩家獲得正確的問題,就不會出現一段時間,直到玩家選擇了兩張牌,我可以如何停止輸入框(用戶如何輸入答案)。如何讓我的代碼在Visual Basic中停止?

我使用兩個數組,一個用於存放問題,另一個用於存放答案。附:請原諒最後幾個問題,試圖在完成所有問題之前將其解決。

Private Sub Questions() strQuestions(0) = "A common noun refers to the name of things." strQuestions(1) = "A pronoun is a word that takes the place of nouns." strQuestions(2) = "'She' is a pronoun that would replace a woman's name." strQuestions(3) = "The days of the week are proper nouns." strQuestions(4) = "'He', 'She' and 'them' are all pronouns." strQuestions(5) = "Spain is a proper noun." strQuestions(6) = "Proper nouns always start with a capital letter." strQuestions(7) = "The place 'England' is referred to as a proper noun." strQuestions(8) = "A 'camera' is a common noun." strQuestions(9) = "FE" strQuestions(10) = "GR" strAnswers(0) = "TRUE" strAnswers(1) = "TRUE" strAnswers(2) = "TRUE" strAnswers(3) = "TRUE" strAnswers(4) = "TRUE" strAnswers(5) = "TRUE" strAnswers(6) = "TRUE" strAnswers(7) = "TRUE" strAnswers(8) = "TRUE" strAnswers(9) = "TRUE" strAnswers(10) = "TRUE" Dim userAnswer As String For i = 0 To UBound(strQuestions) userAnswer = InputBox(strQuestions(i)) If userAnswer strAnswers(i) Then MsgBox("Incorrect. Try again.") Else MsgBox("Correct! Make your move.") WHAT GOES HERE? End If Next i End Sub Private Sub label_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.Click, Label8.Click, Label7.Click, Label6.Click, Label5.Click, Label4.Click, Label3.Click, Label2.Click, Label16.Click, Label15.Click, Label14.Click, Label13.Click, Label12.Click, Label11.Click, Label10.Click, Label1.Click ' The timer is only on after two non-matching ' icons have been shown to the player, ' so ignore any clicks if the timer is running If Timer1.Enabled Then Exit Sub Dim clickedLabel = TryCast(sender, Label) If clickedLabel IsNot Nothing Then End If ' If the clicked label is black, the player clicked ' an icon that's already been revealed -- ' ignore the click If clickedLabel.ForeColor = Color.Black Then Exit Sub ' If firstClicked is Nothing, this is the first icon ' in the pair that the player clicked, ' so set firstClicked to the label that the player ' clicked, change its color to black, and return If firstClicked Is Nothing Then firstClicked = clickedLabel firstClicked.ForeColor = Color.Black Exit Sub End If ' If the player gets this far, the timer isn't ' running and firstClicked isn't Nothing, ' so this must be the second icon the player clicked ' Set its color to black secondClicked = clickedLabel secondClicked.ForeColor = Color.Black CheckForWinner() ' If the player clicked two matching icons, keep them ' black and reset firstClicked and secondClicked ' so the player can click another icon If firstClicked.Text = secondClicked.Text Then firstClicked = Nothing secondClicked = Nothing Questions() Exit Sub End If ' If the player gets this far, the player ' clicked two different icons, so start the ' timer (which will wait three quarters of ' a second, and then hide the icons) Timer1.Start() Questions() Exit Sub

來源

2013-07-09 KSR5

+0

我想你應該會看到一個教程,也許幾個示例應用程序第一次。這是vb.net嗎?他們的方式編碼,現在的問題將被循環詢問。但其餘的代碼看起來像你想要它的事件驅動。這意味着用戶會看到一個問題,然後選擇一個答案? – tgkprog



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有